package nc.ui.arap.buttonstat;

import nc.ui.arap.actions.DefaultAction;
import nc.ui.arap.engine.AbstractRuntime;
import nc.ui.arap.engine.ExtButtonObject;
import nc.ui.arap.engine.IActionRuntime;
import nc.ui.arap.engine.IButtonStatus;
import nc.ui.arap.global.DjTempletHelper;
import nc.ui.ep.dj.ArapBillWorkPageConst;
import nc.vo.arap.exception.ExceptionHandler;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.ep.dj.DJZBVOConsts;
import nc.vo.pub.BusinessException;

public class ListSaveStatlistener extends DefaultAction  implements IButtonStatus {

	public void updateButtonStatus(ExtButtonObject bo, IActionRuntime runtime) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		setActionRunntimeV0(runtime);
		if (!(runtime instanceof AbstractRuntime))
			return;
		AbstractRuntime runt = (AbstractRuntime) runtime;
		bo.setEnabled(false);
		if ( runtime.getCurrWorkPage()==ArapBillWorkPageConst.LISTPAGE&&DjTempletHelper.isListSelectedBill(runt)) {
				
			try {
				for(DJZBVO vo:this.getListAllSelectedVOs() ){
					DJZBHeaderVO head=(DJZBHeaderVO)vo.getParentVO();
					if(DJZBVOConsts.ACT_FLOW_BILL.equals(head.getTransientFlag())&&DJZBVOConsts.m_intDJStatus_UNSaved==head.getDjzt()){
						bo.setEnabled(true);
						bo.setVisible(true);
						break;
					}
				}
			} catch (BusinessException e) {
				// TODO Auto-generated catch block
				ExceptionHandler.consume(e);
			}
				
		}
	}
}
